<!DOCTYPE html>
<html class="no-js  mobile" lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="cleartype" content="on">
    <title>全部订单</title>
    <!-- meta viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <!-- CSS -->
    <!--<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/alertMsg.js"></script>-->
    <!-- <script src="http://sdk.talkingdata.com/app/h5/v1?appid=DE13C350F41F5DE78FEC51DB5DE730D1&vn=v2&vc=v2"></script> -->
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <script src="https://og6593g2z.qnssl.com/fundebug.0.3.3.min.js" apikey="e65b1e28cd641345cd31ef6dce8ac62f7aaa3ba3420be5a1c4aa23ee3636992d"></script>
    <link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
    <link href="{$Think.config.RESOURCEURL}wx_assets/iconfont/iconfont.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
    <link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/product/orderList2.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
    <if condition="$mallHue.mallHue eq '1'">
        <link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/product/orderList1_blue.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
    <else/>
        <link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/product/orderList1.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
    </if>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/product/cookie.js{$Think.config.RESOURCE_VER}"></script>
    <style>
        @font-face {
            font-family: 'iconfont';
            src: url('//at.alicdn.com/t/font_1460607410_4444156.eot'); /* IE9*/
            src: url('//at.alicdn.com/t/font_1460607410_4444156.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
            url('//at.alicdn.com/t/font_1460607410_4444156.woff') format('woff'), /* chrome、firefox */
            url('//at.alicdn.com/t/font_1460607410_4444156.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
            url('//at.alicdn.com/t/font_1460607410_4444156.svg#iconfont') format('svg'); /* iOS 4.1- */
        }
        .iconf {
            font-family:"iconfont" !important;
            font-size:75px;
            font-style:normal;
            -webkit-font-smoothing: antialiased;
            -webkit-text-stroke-width: 0.2px;
            -moz-osx-font-smoothing: grayscale;
            display: block;
            height: 75px;
            color: #ccc;
        }
    </style>
</head>

<body class="order fixed">
  <div class="select-and-search">
    <div class="select-feild">
        <div class="bg"></div>
        <div class="select">
            <span class="selected">普通订单</span><div class="select-icon"><i class="iconfont">&#xe80d;</i></div>
        </div>
        <ul class="options">
            <li class="active" data-type="normal"><span>普通订单</span></li>
            <li data-type="marketing"><span>营销订单</span></li>
            <li data-type="point"><span>积分订单</span></li>
        </ul>
    </div>
    <div class="search-feild">
        <input type="text" class="search-input" placeholder="请输入订单号进行搜索">
        <i class="iconfont">&#xe63c;</i>
    </div>
  </div>
<div >
    <div class="order_status normal" >
        <a onclick="order.statusLink(0, 'buy')">未完成</a>
        <a onclick="order.statusLink(1, 'buy')">待发货</a>
        <a onclick="order.statusLink(2, 'buy')">待收货</a>
        <a onclick="order.statusLink(3, 'buy')">已完成</a>
        <a onclick="order.statusLink(4, 'buy')">退款单</a>
    </div>
    <div class="order_status marketing" style="display: none">
        <a onclick="order.statusLink(5, 'form')">未提交</a>
        <a onclick="order.statusLink(6, 'form')">已提交</a>
        <a onclick="order.statusLink(7, 'form')">已确认</a>
        <a onclick="order.statusLink(8, 'form')">已取消</a>
        <a onclick="order.statusLink(9, 'form')">已退款</a>
    </div>
    <div class="order_status point" style="display: none">
        <a onclick="order.statusLink(10, 'point')">未完成</a>
        <a onclick="order.statusLink(11, 'point')">待发货</a>
        <a onclick="order.statusLink(12, 'point')">待收货</a>
        <a onclick="order.statusLink(13, 'point')">已完成</a>
    </div>
</div>
<div id="order-list-container" >
</div>

<!-- 支付弹窗 -->
<div class="layer-pay">
	<div class="bg"></div>
	<div class="layer-box">
		<ul>
			<li class="item">
				<label>
					<input type="radio" name="payType" checked value="wechat">
					<i class="iconfont" style="color: #04b310;">&#xe619;</i>
					<div>微信支付</div>
				</label>
			</li>
			<li class="item">
				<label>
					<input type="radio" name="payType" value="alipay">
					<i class="iconfont" style="color: #01aaef;">&#xe691;</i>
					<div>支付宝支付</div>
				</label>
			</li>
			<li class="btns">
				<div class="cancel">取消</div>
				<div class="confirm">确定</div>
			</li>
		</ul>
	</div>
</div>
</body>
<script type="text/html" id="emptyTpl">
    <div class="norecord">
        <div class="norecord-div">
            <i class="iconf" style="font-size: 75px;color:#ccc;margin-bottom:30px;display: block;">&#xe601;</i>
            <span style="color:{$mallHue.mainColor||default='#f75493'}">你还没有订单</span>
        </div>
    </div>
</script>
<!-- 普通订单 -->
<script type="text/html" id="Tpl">
    <%if(results){
    for(var i=0;i<results.length;i++){
    var result = results[i];
    %>
    <div class="js-list b-list" id="orderList_<%=result.id%>">
        <li class="block block-order animated">
            <div class="header">
                <span class="font-size-12">订单号：<%=result.serialNumber%></span>
                <span class="js-cancel-order pull-right font-size-12"><%=result.statusCh%></span>
            </div>
            <%if(result.OrderDetailInfo){
            for(var j=0;j<result.OrderDetailInfo.length;j++){
            var product = result.OrderDetailInfo[j];
            if(product) {
            %>
            <div class="block block-list block-border-top-none block-border-bottom-none">
                <div class="block-item name-card name-card-3col clearfix" onclick="order.onDetail('<%=result.fromCustomerId%>','<%=product.id%>','<%=result.qId%>','<%=result.miUid%>')">
                    <a href="javascript:;" data-id="<%=product.id%>" class="thumb">
                        <%if(product.picUrl1&&product.picUrl1[1]){%>
                        <img src="<%=product.picUrl1[1]['picUrl']%>">
                        <%}else{%>
                        <img src="<%=product.picUrl%>">
                        <%}%>
                    </a>
                    <div class="detail">
                        <a href="javascript:;" data-id="<%=product.id%>"><h3><%=product.name%></h3></a>
                        <%if(product.sizeName){%>
                        <p class="sku-detail ellipsis js-toggle-more">
                                        <span name="sizeName" class="c-gray">
                                                <%=product.sizeName%>
                                        </span>
                            &nbsp;
                                        <span name="colorName" class="c-gray">
                                            <%=product.colorName%>
                                        </span>
                        </p>
                        <%}%>
                    </div>
                    <div class="right-col">
                        <div class="price">￥<span><%=product.price%></span></div>
                        <div class="num">
                            ×<span class="num-txt"><%=product.reserveCount%></span>
                        </div>
                    </div>
                </div>
            </div>
            <%}%>
            <%}%>
            <div class="bottom" style="height: 26px;line-height: 26px;">
                <span style="float: left;line-height: 31px;">共<%=result.totalCount%>件商品</span>
                商品金额合计：<span class="pinkFont">￥</span><span class="pinkFont" style="font-size:20px;"><%=result.price%></span>
            </div>
            <div class="opt-btn">
                <%if(result.status=='paying'||result.status=='notsubmit'){%>
                <a class="btn btn-in-order-list pinkBack" style="color: white;border: 0px;padding:5px 4px;float: right;" href="javascript:;" onclick="order.onOrderDetail(this,'<%=result.id%>')">立即支付</a>
                <%}else{%>
                <a class="btn bottom-fix btn-in-order-list" href="javascript:;" onclick="order.onOrderDetail(this,'<%=result.id%>')">详情</a>
                <%}%>
                <%if(result.freebuy=="1"){%>
                <a class="btn btn-in-order-list" href='javascript:;' onclick="order.toView('<%=result.id%>')">查看进度</a>
                <%}%>
                <%if(result.orderType==3){%>
                <a class="btn btn-in-order-list" href='javascript:;' onclick="order.toIndianaView('<%=result.id%>')">夺宝详情</a>
                <%}%>
                <%if(result.isTeam==1&&result.status!='notsubmit'&&result.status!='paying'){%>
                <a class="btn btn-in-order-list" href='javascript:;' onclick="order.toTeamDetail('<%=result.teamId%>','<%=result.qId%>','<%=result.miUid%>')">组团详情</a>
                <%}%>
                <%if(result.status=='notsubmit'||result.status=='paying'){%>
                <a class="btn bottom-fix btn-in-order-list" href="javascript:;"  data-serialNumber="<%=result.serialNumber%>" data-id="<%=result.id%>" onclick="order.onCancel(this,'<%=result.id%>')">取消订单</a>
                <%}%>
                <%if(result.status=='delivered'){%>
                <a id="btnwl_<%=result.id%>" class="btn bottom-fix btn-in-order-list" onclick="order.logistics('<%=result.expressName%>','<%=result.expressNo%>','<%=result.id%>')" >查看物流</a>
                <a id="btnSh_<%=result.id%>" style="color: white;border: 0px;padding:5px 4px;float: right;" class="btn btn-orange btn-in-order-list pinkBack" href="javascript:;" data-oid="<%=result.id%>" onclick="order.receipt(this)">确认收货</a>
                <%}%>
            </div>
            <%}%>
        </li>
    </div>
    <%}%>
    <%}else{%>
    <div class="list-finished" evttag="loadMore"
         id="load-more">已经没有更多订单了！</div>
    <div class="list-finished"></div>
    <%}%>
</script>
<!-- 营销订单 -->
<script type="text/html" id="marketing-tpl">
    <%if(results){
    for(var i=0;i<results.length;i++){
    var result = results[i];
    %>
    <div class="js-list b-list" id="orderList_<%=result.id%>">
        <li class="block block-order animated">
            <div class="header">
                <span class="font-size-12">订单号：<%=result.serialNumber%></span>
                <span class="js-cancel-order pull-right font-size-12"><%=result.statusCh%></span>
            </div>
            <%if(result.OrderDetailInfo){
            for(var j=0;j<result.OrderDetailInfo.length;j++){
            var product = result.OrderDetailInfo[j];
            if(product) {
            %>
            <div class="block block-list block-border-top-none block-border-bottom-none">
                <div class="block-item name-card name-card-3col clearfix">
                    <div class="detail form">
                        <a href="javascript:;" data-id="<%=product.id%>"><h3><%=product.name%></h3></a>
                    </div>
                </div>
            </div>
            <%}%>
            <%}%>
            <%if(result.price > 0){%>
                <div class="bottom" style="height: 26px;line-height: 26px;">
                    订单金额：<span class="pinkFont">￥</span><span class="pinkFont" style="font-size:20px;"><%=result.price%></span>
                </div>
            <%}%>
            <div class="opt-btn">
                <!-- 支付按钮 -->
                <%if(result.status=='paying'||result.status=='notsubmit'){%>
                <a class="btn btn-in-order-list pinkBack" style="color: white;border: 0px;padding:5px 4px;float: right;" href="javascript:;" onclick="order.handlePayBtnClick(this,'<%=result.id%>')">立即支付</a>
                <%}else{%>
                <!-- 详情按钮 -->
                <a class="btn bottom-fix btn-in-order-list" href="javascript:;" onclick="order.onOrderDetail(this,'<%=result.id%>', 'marketing')">详情</a>
                <%}%>
                <!-- 退款按钮 -->
                <%if(result.status == 'delivering'){%>
                <a class="btn btn-in-order-list pinkBack" style="color: white;border: 0px;padding:5px 4px;float: right;" href="javascript:;" onclick="order.refundOrder(this,'<%=result.id%>')">申请退款</a>
                <%}%>
            </div>
            <%}%>
        </li>
    </div>
    <%}%>
    <%}else{%>
    <div class="list-finished" evttag="loadMore"
         id="load-more">已经没有更多订单了！</div>
    <div class="list-finished"></div>
    <%}%>
</script>

<!-- 积分订单 -->
<script type="text/html" id="point-tpl">
    <%if(results){
    for(var i=0;i<results.length;i++){
    var result = results[i];
    %>
    <div class="js-list b-list" id="orderList_<%=result.id%>">
        <li class="block block-order animated">
            <div class="header">
                <span class="font-size-12">订单号：<%=result.serialNumber%></span>
                <span class="js-cancel-order pull-right font-size-12"><%=result.statusCh%></span>
            </div>
            <%if(result.OrderDetailInfo){
            for(var j=0;j<result.OrderDetailInfo.length;j++){
            var product = result.OrderDetailInfo[j];
            if(product) {
            %>
            <div class="block block-list block-border-top-none block-border-bottom-none">
                <div class="block-item name-card name-card-3col clearfix" onclick="order.onDetail('<%=result.fromCustomerId%>','<%=product.id%>','<%=result.qId%>','<%=result.miUid%>')">
                    <a href="javascript:;" data-id="<%=product.id%>" class="thumb">
                        <%if(product.picUrl1&&product.picUrl1[1]){%>
                        <img src="<%=product.picUrl1[1]['picUrl']%>">
                        <%}else{%>
                        <img src="<%=product.picUrl%>">
                        <%}%>
                    </a>
                    <div class="detail">
                        <a href="javascript:;" data-id="<%=product.id%>"><h3><%=product.name%></h3></a>
                        <%if(product.sizeName){%>
                        <p class="sku-detail ellipsis js-toggle-more">
                                        <span name="sizeName" class="c-gray">
                                                <%=product.sizeName%>
                                        </span>
                            &nbsp;
                                        <span name="colorName" class="c-gray">
                                            <%=product.colorName%>
                                        </span>
                        </p>
                        <%}%>
                    </div>
                    <div class="right-col">
                        <div class="price"><span><%=product.points%>积分</span></div>
                        <div class="num">
                            ×<span class="num-txt"><%=product.reserveCount%></span>
                        </div>
                    </div>
                </div>
            </div>
            <%}%>
            <%}%>
            <div class="bottom" style="height: 26px;line-height: 26px;">
                <span style="float: left;line-height: 31px;">共<%=result.totalCount%>件商品</span>
                商品积分合计：<span class="pinkFont"></span><span class="pinkFont" style="font-size:20px;"><%=result.points%>积分</span>
            </div>
            <div class="opt-btn">
                <%if(result.status=='paying'||result.status=='notsubmit'){%>
                <a class="btn btn-in-order-list pinkBack" style="color: white;border: 0px;padding:5px 4px;float: right;" href="javascript:;" onclick="order.onOrderDetail(this,'<%=result.id%>')">立即支付</a>
                <%}else{%>
                <a class="btn bottom-fix btn-in-order-list" href="javascript:;" onclick="order.onOrderDetail(this,'<%=result.id%>')">详情</a>
                <%}%>
                <%if(result.freebuy=="1"){%>
                <a class="btn btn-in-order-list" href='javascript:;' onclick="order.toView('<%=result.id%>')">查看进度</a>
                <%}%>
                <%if(result.orderType==3){%>
                <a class="btn btn-in-order-list" href='javascript:;' onclick="order.toIndianaView('<%=result.id%>')">夺宝详情</a>
                <%}%>
                <%if(result.isTeam==1&&result.status!='notsubmit'&&result.status!='paying'){%>
                <a class="btn btn-in-order-list" href='javascript:;' onclick="order.toTeamDetail('<%=result.teamId%>','<%=result.qId%>','<%=result.miUid%>')">组团详情</a>
                <%}%>
                <%if(result.status=='notsubmit'||result.status=='paying'){%>
                <a class="btn bottom-fix btn-in-order-list" href="javascript:;"  data-serialNumber="<%=result.serialNumber%>" data-id="<%=result.id%>" onclick="order.onCancel(this,'<%=result.id%>')">取消订单</a>
                <%}%>
                <%if(result.status=='delivered'){%>
                <a id="btnwl_<%=result.id%>" class="btn bottom-fix btn-in-order-list" onclick="order.logistics('<%=result.expressName%>','<%=result.expressNo%>','<%=result.id%>')" >查看物流</a>
                <a id="btnSh_<%=result.id%>" style="color: white;border: 0px;padding:5px 4px;float: right;" class="btn btn-orange btn-in-order-list pinkBack" href="javascript:;" data-oid="<%=result.id%>" onclick="order.receipt(this)">确认收货</a>
                <%}%>
            </div>
            <%}%>
        </li>
    </div>
    <%}%>
    <%}else{%>
    <div class="list-finished" evttag="loadMore"
         id="load-more">已经没有更多订单了！</div>
    <div class="list-finished"></div>
    <%}%>
</script>

<script>
    var hrefParamsArray = GetSessionIdFromHref(window.location.search);
    hrefParamsArray["userName"]='{$userName}';
    function GetSessionIdFromHref(search){
    　　  var args = search.substring(1);
　　  var retval = new Array();
        args = args.split("&");
        for(var i = 0; i < args.length; i ++){
            str = args[i];
            var arg = str.split("=");
            if(arg.length <= 1) continue;

            if(arg[0] == 'params') {
                var params = decodeURIComponent(arg[1]);
                var obj = eval('(' + params + ')');
                if (obj.rootid != undefined) {
                    retval["rootid"] = obj.rootid;
                }
                if (obj.start != undefined) {
                    retval["start"] = obj.start;
                }
                if (obj.status != undefined) {
                    retval["status"] = obj.status;
                }
            } else if(arg[0] == 'customerId') {
                retval["customerId"] = arg[1];
            }else if(arg[0] == 'userName'){
                retval["userName"] = arg[1];
            }
        }
        if (retval["start"] == undefined) {
            retval["start"] = 0;
        }
        return retval;
    }
</script>
<script>
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var order = {
        type: 'buy',
        pageSize:10,
        page:0,
        status:0,
        orderId: '',
        init:function(){
            var me=this;
            this._initEvent();
            $.util.pageLoading.show();
            this._initTab();
            this.bindEvents();
        },
        _initTab:function(){
            var me=this;
            var status = getCookie('orderListStatus') || 0;
            if (status < 5) {
              me.statusLink(status, 'buy');
            } else if (status < 10) {
              me.statusLink(status, 'form');
              $('.order_status.marketing').css('display', '-webkit-box');
              $('.order_status.normal').css('display', 'none');
              $('.select-feild .selected').text('营销订单');
              $('.select-feild .options li').eq(1).addClass('active')
              .siblings().removeClass('active');
            } else {
              me.statusLink(status, 'point');
              $('.order_status.point').css('display', '-webkit-box');
              $('.order_status.normal').css('display', 'none');
              $('.select-feild .selected').text('积分订单');
              $('.select-feild .options li').eq(2).addClass('active')
              .siblings().removeClass('active');
            }
        },
        bindEvents: function() {
            var me = this;
            $('.select').click(function(){
                $('.select-feild').toggleClass('active');
            });
            $('.select-feild .bg').click(function(){
                $('.select-feild').removeClass('active');
            });

            $('.select-feild li').click(function() {
              var type = $(this).data('type')
                $('.select-feild li').removeClass('active');
                $(this).addClass('active');
                $('.select-feild .selected').html($(this).find('span').text());
                $('.select-feild').removeClass('active');

                $('.order_status').css('display', 'none');
                me.page = 1;
                if (type === 'normal') {
                    $('.normal').css('display', '-webkit-box');
                    me.statusLink(0, 'buy');
                } else if (type === 'marketing') {
                    $('.marketing').css('display', '-webkit-box');
                    me.statusLink(5, 'form');
                } else if (type === 'point') {
                  $('.point').css('display', '-webkit-box');
                  me.statusLink(10, 'point');
                }
            });
            $('.search-feild input').on('blur', function () {
                $.util.pageLoading.show();
                order._loadList(order.page,function(){
                    $.util.pageLoading.hide();
                });
            })
            $('.search-feild input').on('keyup', function (event) {
                if (event.keyCode == 13) {
                    $.util.pageLoading.show();
                    order._loadList(order.page,function(){
                        $.util.pageLoading.hide();
                    });
                }
            })
            $('.cancel').click(function(){
              $('.layer-pay').css('display', 'none');
            })
        },
        // 点击立即支付按钮
        handlePayBtnClick:function(ctrl, orderId){
          var that = this;
          $('.layer-pay').css('display', 'block');
          $('.confirm').click(function(){
            that.handlePayFormOrderBtnClick(orderId)
          })
        },
        // 点击确认按钮支付
    		handlePayFormOrderBtnClick: function(orderId) {
    			var payType = ''
    			$('input[name=payType]').each(function(){
    				if ($(this).attr('checked') == true) payType = $(this).val();
    			})
    			if (payType == 'wechat') {
    				this.formOrderPay(orderId, 'wxpay');
    			} else {
    				this.formOrderPay(orderId, 'alipay');
    			}
    		},
        formOrderPay: function(orderId, payType) {
          this.orderId = orderId;
    			this.payType = payType;
          var params = {
    			    orderId: orderId,
    			    payType: payType || ''
          }
          $.ajax({
              type: 'get',
              url: '{$Think.config.SERVER_HOST}call.json?customerId={$customerId}',
              dataType: 'json',
              data: {
                 module: "product",
                 method: "formOrderPay",
                 params: JSON.stringify(params)
              },
              success: $.proxy(this.handleFormOrderPaySucc, this),
              error: $.proxy(this.handleAjaxError, this)
          });
        },
        handleFormOrderPaySucc: function(res) {
    			var that = this
    			if (this.payType == 'wxpay') {
    				try {
    	        window.WeixinJSBridge.invoke('getBrandWCPayRequest', res.pkg, function (res) {
    	          if (res.err_msg === 'get_brand_wcpay_request:ok') {
    							$('.layer-pay').css('display', 'none');
    							that.statusLink(6, 'form');
    	          } else {
    	            if (res.err_msg === 'get_brand_wcpay_request:cancel') {
    	              return $.util.alert('操作已取消');
    	            } else if (res.err_msg === 'get_brand_wcpay_request:fail') {
    	              return $.util.alert('网络错误发送失败，请稍后再试');
    	            } else if (res.err_msg === 'access_control:not_allow' || res.err_msg === 'system:access_denied') {
    	              return $.util.alert('商家尚未开通微信支付');
    	            } else {
    	              return $.util.alert(res.err_msg);
    	            }
    	          }
    	        })
    	      } catch (e) {
    	        $.util.alert('操作失败，请确保在微信浏览器中操作');
    	      }
    			} else if (this.payType == 'alipay') {
    				sessionStorage.setItem('orderType', 'marketing');
    				location.href = '{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=product&method=orderBrowserOpen&params=%7B%22id%22%3A%22' + this.orderId + '%22%7D'
    			} else {
    				$.util.alert(res.msg);
    			}
    		},

    		// ajax失败后执行
    		handleAjaxError: function(err) {
    			$.util.alert(err)
    		},
        refundOrder: function(ctrl, id) {
          var that = this;
          $.util.ok("如果您对我们的产品不满意，我们即刻为您办理退款，妥妥的！",function(){
            var urlString = 'call.json?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"];
            $.ajax({
                url: urlString,
                dataType: "json",
                type: "POST",
                data: {
                    module: 'product',
                    method: 'productOrderRefund',
                    params: '{"id":"' + id + '"}'
                },
                success:function(b){
                    if (b.code == 0) {
                        that.statusLink(8, 'form');
                    } else {
                        $.util.alert(b.msg);
                    }
                }
            });
          });
        },
        statusLink:function(s, type){
            $('#dataEnd').remove()
            var me = this;
            if(type) me.type = type;
            var ctl = $(".order_status a:eq("+s+")");
            $('.search-feild input').val('');
            // if(ctl.hasClass("active")){return;}
            ctl.addClass("active").siblings("a").removeClass("active");
            if (s > 9) {
              order.status = s - 10;
            } else if (s > 4 && s < 7) {
                order.status = s - 5;
            } else if (s >= 7) {
                order.status = s - 4;
            } else {
                order.status = s;
            }
            console.log(s)
            setCookie('orderListStatus', s);
            order.page=0;
            $.util.pageLoading.show();
            order._loadList(order.page,function(){
                $.util.pageLoading.hide();
            });
        },
        _initEvent:function(){
            var me=this;
            $.util.initDataLoading({
                me:order,
                lastChildren:function(){
                    return $("#order-list-container .js-list:last");
                },
                page:function(){
                    return order.page;
                },
                pageCount:function(){
                    return order.pageCount;
                }
            });
        },
        _renderList:function(data,page,callback){
            var me=this;
            if(data){
                if(data.results){
                    data.results = order.orderStatus(data.results);
                }
                var html = ''
                var container = $("#order-list-container")
                if(!data.pageCount){
                  html = template("emptyTpl", data)
                }else if (order.type == 'buy') {
                  html = template("Tpl", data)
                } else if (order.type === 'form') {
                  html = template("marketing-tpl", data)
                } else if (order.type === 'point') {
                  html = template("point-tpl", data)
                }
                if(page){
                    container.append(html);
                }else{
                    container.html(html);
                }
                me.page=page;
                me.pageCount=data.pageCount;
                callback && callback();
            }
        },
        _loadList:function(page,callback){
            var me=this;
            $.req.get("call.json?module=product&customerId={$customerId}&method=getOrder",{
                userName:"{$userName}",
                params: {
                    "tplid":1,
                    "type": me.type,
                    "start": page,
                    "limit": me.pageSize,
                    "status": me.status,
                    "search": $('.search-feild input').val()
                }
            },function(data){
                if(data){
                    me._renderList(data,page,callback);
                }
            });
        },
        orderStatus:function (data){
            for(var i=0;i<data.length;i++){
                switch(data[i].status){
                    case 'ok':
                        data[i].statusCh='交易成功';
                        break;
                    case 'closed':
                        data[i].statusCh='交易关闭';
                        break;
                    case 'paying':
                        data[i].statusCh='等待付款';
                        break;
                    case 'delivering':
                        data[i].statusCh='等待发货';
                        break;
                    case 'delivered':
                        data[i].statusCh='已发货';
                        break;
                    case 'notsubmit':
                        data[i].statusCh='未提交';
                        break;
                    case 'refund':
                        data[i].statusCh='已退款';
                        break;
                    case 'refundedpart':
                        data[i].statusCh='已部分退款';
                        break;
                    case 'refunding':
                        data[i].statusCh='退款中';
                        break;
                    case 'payingconfirm':
                        data[i].statusCh='付款确认中';
                        break;
                    case 'paypart':
                        data[i].statusCh='部分付款';
                        break;
                    case 'teaming':
                        data[i].statusCh='组团中';
                        break;
                    case 'partake':
                        data[i].statusCh='已参与夺宝';
                        break;
                    case 'deliveringtostore':
                        data[i].statusCh='等待配送自提点';
                        break;
                    case 'deliveredtostore':
                        data[i].statusCh='已配送到自提点';
                        break;
                    case 'ordersign':
                        data[i].statusCh='已报名';
                        break;
                    case 'confirmsign':
                        data[i].statusCh='已确认报名';
                        break;
                    case 'canclesign':
                        data[i].statusCh='已取消报名';
                        break;
                    case 'supported':
                        data[i].statusCh='众筹中';
                        break;
                    case 'submission':
                        data[i].statusCh='已提交';
                        break;
                    case 'cancel':
                        data[i].statusCh='已取消';
                        break;
                    default :
                        data[i].statusCh='状态错误';
                        break;
                }
                // 营销订单映射
                if (order.type == 'form') {
                    switch(data[i].status){
                        case 'ok':
                            data[i].statusCh='已确认';
                            break;
                        case 'paying':
                            data[i].statusCh='待付款';
                            break;
                        case 'delivering':
                            data[i].statusCh='已付款';
                            break;
                        case 'refund':
                            data[i].statusCh='已退款';
                            break;
                        case 'refundedpart':
                            data[i].statusCh='已部分退款';
                            break;
                        case 'submission':
                            data[i].statusCh='已提交';
                            break;
                        case 'closed':
                            data[i].statusCh='已关闭';
                            break;
                        case 'cancel':
                            data[i].statusCh='已取消';
                            break;
                    }
                }

            }
            return data;
        },
        toComment:function (oid,pid){
            var params={
                "oid":oid,
                "pid":pid
            }
            params=encodeURIComponent(JSON.stringify(params));
            location.href= 'call.html?customerId={$customerId}&module=product&method=getcomment&params='+params;
        },
        logistics:function (expressName,expressNo,oid){
            var url = '{$Think.config.SERVER_HOST}';
            var cid = '{$customerId}';
            location.href=url+'call.html?customerId='+cid+'&module=product&method=productExpress&params={"Express":"'+expressName+'","orderNum":"'+expressNo+'","oid":"'+oid+'"}';
        },
        onCancel:function (ctrl,id) {
            $.util.ok("确定取消订单吗？",function() {
                var urlString = 'call.json?customerId={$customerId}&userName='+hrefParamsArray["userName"];
                $.ajax({
                    url: urlString,
                    dataType: "json",
                    type: "POST",
                    data: {
                        module: 'product',
                        method: 'cancelOrder',
                        params: '{"id":' + parseInt(id) + ',"status":"ok"}'
                    },
                    success:function(data){
                        if (!data.code) {
                            $("#orderList_"+id).remove();
                        } else {
                            $.util.alert(b.msg);
                        }
                    }
                });
            });
        },
        toView :function(id){
            location.href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=freebuy&method=getView&params=%7B"oid"%3A"'+id+'"%7D';
        },
        toIndianaView:function(id){
            location.href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=allChips&method=getIndianaDetail&params=%7B"oid"%3A"'+id+'"%7D';
        },
        toTeamDetail:function(id,qid,miuid){
            var p={
                qId:qid,
                miUId:miuid,
                teamId:id
            };
            p=encodeURIComponent(JSON.stringify(p));
            location.href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&module=tuan&method=getView&params='+p;
        },
        onOrderDetail:function (ctrl, id, type) {
            var rootid = '';
            if (hrefParamsArray["rootid"] !== undefined) {
                rootid = ',"rootid":' + hrefParamsArray["rootid"];
            }
            if (type === 'marketing') {
                ctrl.href = 'call.html?userName=' + hrefParamsArray['userName'] + '&customerId='
            + hrefParamsArray['customerId'] + '&force=1&module=product&method=getOrderDetail&params={"id":"' + id
            + rootid + '"}';
            } else {
                ctrl.href = 'call.html?userName=' + hrefParamsArray['userName'] + '&customerId='
            + hrefParamsArray['customerId'] + '&force=1&module=product&method=getOrderDetail&params={"tplid":1,"id":"' + id
            + rootid + '"}';
            }
        },
        onDetail:function(fromCustomerId,id,qId,miUid) {
            var params={
                "id":id,
                "qId":qId,
                "miUId":miUid
            }
            params=encodeURIComponent(JSON.stringify(params));
            location.href= 'call.html?customerId='+fromCustomerId+'&module=product&method=getProduct&params='+params;
        },
        receipt:function(ctrl){
            var oid = $(ctrl).attr("data-oid");
            $.util.ok("确定已经收到货物了吗？",function(){
                $.util.pageLoading.show();
                var urlString = 'call.json?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"];
                $.ajax({
                    url: urlString,
                    dataType: "json",
                    type: "POST",
                    data: {
                        module: 'product',
                        method: 'setOrderStatus',
                        params: '{"oid":' + parseInt(oid) + ',"status":"ok"}'
                    },
                    success:function(b){
                        if(!b.code){
                            $(ctrl).parents("li").remove();
                            $.util.pageLoading.hide();
                        }else{
                            $.util.alert(d.msg);
                            $.util.pageLoading.hide();
                        }
                    },
                    error:function(){
                        location.reload();
                    }
                });
            });
        }
    };
    order.init();

</script>
</html>
